credit scheduler: fix credits overflow
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 2 Oct 2009 08:10:27 +0000 (09:10 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 2 Oct 2009 08:10:27 +0000 (09:10 +0100)
commit4f74c85e698b5ba44c9449cc06bdd5c7af3aa2b7
tree28425072f7bbb666d04bf0caccfc29a229295c8e
parent3ec6777498773932c6383c2bfc7b05523f6ca45f
credit scheduler: fix credits overflow

In changing credits-per-tick from 100 to 1000000, a possible overflow
was introduced in the accounting algorithm, when credit totals (which
can be in the millions) gets multiplied by a weight (typically 256):
th eresult can easily overflow a signed 32-bit variable.

Fix this by reverting to 100 credits per tick, and maintain long-term
fairness/correctness by tracking at the nanosecond level exactly how
much execution time has been accounted to each VCPU. We do this by
rounding execution time so far to nearest number of credits, but then
remember the VCPU's 'partial credit balance'.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/common/sched_credit.c